package view.exten;

import com.google.gson.Gson;
import view.SuperView;

import java.io.IOException;
import java.io.PrintWriter;

public class JsonView extends SuperView {
    private String str;
    private Gson gson;

    public JsonView(Gson gson){
        this.gson=gson;
        this.str=new Gson().toJson(gson);
        handle();
    }

    public JsonView(String str){
        this.str=str;
        handle();
    }

    @Override
    protected void handle() {
        try {
            PrintWriter out=resp.getWriter();
            out.println(str);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
